home *** CD-ROM | disk | FTP | other *** search
- Path: erich.triumf.ca!bennett
- From: bennett@erich.triumf.ca (P.Bennett)
- Newsgroups: comp.lang.c
- Subject: Re: help with program
- Date: 16 Apr 1996 15:19 PST
- Organization: TRIUMF: Tri-University Meson Facility
- Distribution: world
- Message-ID: <16APR199615190586@erich.triumf.ca>
- References: <4kkgde$t2m@news.duke.edu> <4kvl0e$g4c@hpbblb.bbn.hp.com>
- NNTP-Posting-Host: erich.triumf.ca
- News-Software: VAX/VMS VNEWS 1.50
-
- In article <4kvl0e$g4c@hpbblb.bbn.hp.com>, Matthias Dittrich <matti> writes...
- >kev@acpub.duke.edu (Kevin Daniels) wrote:
- >>
- >>Can anyone tell me why the following slice of code might be giving the
- >>unwanted behavior shown below?
- ..snip...
- >> printf("\n\nmove from row -> ");
- >> scanf("%d",&curr_row);
- >> printf("\n\nmove from col -> ");
- >> scanf("%d",&curr_col);
- >> printf("\n\nmove to row -> ");
- >> scanf("%d",&dest_row);
- >> printf("\n\nmove to col -> ");
- >> scanf("%d",&dest_col);
- >>
- .. more snippage...
-
- >The function scanf() requires a '\n' character to accept input. You have to
- >remove this character from the input stream. A call of fflush(stdin) before
- >each scanf() should work.
-
- No. successive scanf()s will work OK - each one sees the '\n' left by the
- previous one as "whitespace" and eats it, before reading the new input. The
- leftover '\n' is only a problem if you mix scanf() and getchar() or other
- input functions.
-
- The action of fflush() on input streams is undefined - on some systems it _may_
- clear the input buffer, but this is not required by the standard.
-
-
- Peter Bennett VE7CEI | Vessels shall be deemed to be in sight
- Internet: bennett@triumf.ca | of one another only when one can be
- Packet: ve7cei@ve7kit.#vanc.bc.ca | observed visually from the other
- TRIUMF, Vancouver, B.C., Canada | ColRegs 3(k)
- GPS and NMEA info and programs: ftp://sundae.triumf.ca/pub/peter/index.html
- or: ftp://ftp-i2.informatik.rwth-aachen.de/pub/arnd/GPS/peter/index.html
- or: http:://vancouver-webpages.com/peter/index.html
-
-
-
-
-
-
-